﻿@using GoodMan.Infrastructure.Entities.Entity;
@{
    ViewBag.Title = "限时特卖详情";
    Layout = "~/Areas/WorkSpace/Views/Shared/_CollegeAdminTemplete.cshtml";
    int productId = ViewBag.ProductID == null ? 0 : ViewBag.ProductID;
    Product product = ViewBag.Product == null ? new Product() : ViewBag.Product;
    List<Policy> policys = ViewBag.Policys == null ? new Policy() : ViewBag.Policys;
    int type = ViewBag.Type == null ? 0 : ViewBag.Type;
}
<div id="content-header">
    <h1>
        限时特卖</h1>
</div>
<div id="breadcrumb">
    <a href="index.html" title="Go to Home" class="tip-bottom"><i class="icon-home"></i>
        首页</a> <a href="#" class="tip-bottom">商品管理</a> <a href="#" class="current">限时特卖</a>
    <a href="#" class="current">设置</a>
</div>
<div class="container-fluid">
    <div class="row-fluid">
        <div class="span12">
            <div class="widget-box">
                <div class="widget-title">
                    <span class="icon"><i class="icon-th"></i></span>
                    <h5>
                        限时特卖详情</h5>
                </div>
                <div class="widget-content nopadding">
                    <form action="/CollegeAdmin/SaveSpecialSale" method="post" id="fromSetSpecialSale" class="form-horizontal">
                     <input type="hidden" id="productId" name="productId" value="@productId" />
                     <input type="hidden" id="type" name="type" value="@type" />
                    <table border="0" cellpadding="0" cellspacing="0" width="100%">
                        <tr>
                            @{
                                if(productId>0)
                                {
                                           <td rowspan="2" width="320">
                                        <div class="controls" style="margin-left: 30px;">
                                            <img width="280" height="280" alt="User" src="@product.Images" />
                                        </div>
                                    </td>
                                    <td style="vertical-align: top;">
                                        <div style="margin-left: 30px; margin-top: 20px;white-space:normal; word-break:break-all;overflow:hidden;">
                                            <h3>
                                                @product.ProductName</h3>
                                        </div>
                                    </td> 
                                }
                                else
                                {
                                    <td rowspan="2" width="320">
                                <div class="controls" style="margin-left: 30px;">
                                    <img width="280" height="280" alt="User" src="" />
                                </div>
                            </td>
                            <td style="vertical-align: top;">
                                <div style="margin-left: 30px; margin-top: 20px">
                                    <h3>
                                        康师傅袋装方便面</h3>
                                </div>
                            </td>
                                }
                            }
                             
                        </tr>
                        <tr>
                            <td>
                                <div class="control-group">
                                    <label class="control-label" style="margin-left: 10px; width: 80px">
                                        购入价格</label>
                                    <div class="controls" style="margin-left: 100px;">
                                        <span><strong><font color="red">@product.PurchasePrice</font></strong></span>
                                    </div>
                                </div>
                                <div class="control-group">
                                    <label class="control-label" style="margin-left: 10px; width: 80px">
                                        特卖价格</label>
                                    <div class="controls" style="margin-left: 100px;">
                                        <input type="text" name="specialprice" placeholder="输入特卖价格" style="width: 100px" class="span4 {required:true,number:true,min:0.01,messages:{required:'销售价格格式错误'}}"/><span style="color:Red;font-size:20px">&nbsp;&nbsp;*</span>
                                    </div>
                                </div>
                                <div class="control-group">
                                    <label class="control-label" style="margin-left: 10px; width: 80px">
                                        开始时间</label>
                                    <div class="controls" style="margin-left: 100px;">
                                        <input type="text" name="startdate" onClick="WdatePicker({skin:'blue',dateFmt:'yyyy-MM-dd HH:mm:ss'})" readonly="readonly" style="width: 200px" class="span4 {required:true,messages:{required:'开始时间不能为空'}}"/><span style="color:Red;font-size:20px">&nbsp;&nbsp;*</span>
                                    </div>
                                </div>
                                <div class="control-group">
                                    <label class="control-label" style="margin-left: 10px; width: 80px">
                                        结束时间</label>
                                    <div class="controls" style="margin-left: 100px;">
                                        <input type="text" name="enddate" onClick="WdatePicker({skin:'blue',dateFmt:'yyyy-MM-dd HH:mm:ss'})"  readonly="readonly" style="width: 200px" class="span4 {required:true,messages:{required:'开始时间不能为空'}}"/><span style="color:Red;font-size:20px">&nbsp;&nbsp;*</span>
                                    </div>
                                </div>
                                <div class="control-group">
                                    <div class="controls" style="margin-left: 100px;">
                                        <button type="submit" class="btn btn-primary">
                                            保存</button>&nbsp;&nbsp;&nbsp;&nbsp;<a href="javascript:history.go(-1);"  style="margin-top:10px">返回</a>
                                    </div>
                                </div>
                            </td>
                        </tr>
                    </table>
                    </form>
                </div>
                 <div class="widget-title">
                    <span class="icon"><i class="icon-th"></i></span>
                    <h5>
                        商品历史限时特卖</h5>
                </div>
                <div class="widget-content nopadding">
                <table class="table table-bordered data-table">
									<thead>
									<tr>
                                    <th width="10%">价格类型</th>
									<th width="25%">开始时间</th>
									<th width="25%">结束时间</th>
									<th  width="10%">购入价格</th>
									<th  width="10%">特卖价格</th>
                                    <th  width="10%">状态</th>
                                     <th  width="10%">操作</th>
									</tr>
									</thead>
									<tbody>
                                    @{
                                        if (policys != null && policys.Any())
                                        {
                                            var nowtime = DateTime.Now;
                                            string stateStr="";
                                            int state=0;
                                            int viewbtn=0;
                                            foreach (var item in policys)
                                            { 
                                                if(item.IsActive)
                                                {
                                                    if(nowtime>item.StartDate&&nowtime<item.ExpireDate)
                                                    {
                                                        stateStr = "进行中";
                                                        viewbtn = 1;
                                                    }
                                                    else if(nowtime<item.StartDate)
                                                    {
                                                        stateStr = "待启用";
                                                    }
                                                    else if(nowtime>item.ExpireDate)
                                                    {
                                                        stateStr = "已过期";
                                                    }
                                                }
                                                else
                                                {
                                                    stateStr = "已禁用";
                                                    viewbtn = 1;
                                                    state = 1;
                                                }
                                                    if(item.PolicyType==1)
                                                    {
                                                        <tr class="gradeX">
                                                        <td>默认价格</td>
                                                         <td>永久</td>
                                                        <td>永久</td>
									                    <td>@product.PurchasePrice</td>
                                                        <td>@item.Price</td>
									                    <td style="color:Red">启用</td>
									                    <td class="center"></td> 
                                                        </tr>
                                                    }
                                                    else
                                                    {
                                                        <tr class="gradeX">
                                                         <td>限时特卖</td>
                                                          <td>@item.StartDate</td>
                                                        <td>@item.ExpireDate</td>
									                    <td>@product.PurchasePrice</td>
                                                        <td>@item.Price</td>
									                    <td style="color:Red">@stateStr</td>
                                                          
									                    <td class="center">
                                                        @{if(viewbtn==1)
                                                        {
                                                        @:<a href="/workspace/CollegeAdmin/ModifySpecailSale?productId=@productId&Id=@item.Id&type=@type&state=@state" class="btn btn-danger btn-mini">
                                                        if(state==1)
                                                        {
                                                            <span>启用</span>
                                                        }
                                                        else
                                                        {
                                                            <span>停止</span>
                                                        }
                                                         @:</a>
                                                            }
                                                            
                                                         }</td>
                                                        </tr>
                                                    }
                                                }
                                            }
                                        }
									 
									 
									</tbody>
									</table>  
                </div>
            </div>
        </div>
    </div>
</div>
@section tail{
<script type="text/javascript">    $(function () {
        $('#likProduct').addClass('open');
        $('#likProduct').addClass('active');
    }); </script>

    <script type="text/javascript" src="/Scripts/jquery.validate.js"></script>
    <script type="text/javascript" src="/Scripts/jquery.metadata.js"></script>
<script type="text/javascript">
    var validation = new plug.BindValidCode();
    $(function () {
        validation.BindValidator();

        $('#productDetailForm').validate({
            errorClass: "help-inline",
            errorElement: "span",
            highlight: function (element, errorClass, validClass) {
                $(element).parents('.control-group').addClass('error');
            },
            unhighlight: function (element, errorClass, validClass) {
                $(element).parents('.control-group').removeClass('error');
            }
        });
    });
    function Refalsh(sender) {
        validation.Refalsh(sender);
    }
    </script>
}
